package com.snowflake.ecatalog.entity;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.snowflake.ecatalog.contant.Status;

/**
 * 商品分类
 */
// JPA标识
@Entity
@Table(name = "t_ec_gcategory")
public class GoodsCategory extends OpEntity {
	private Profile profile;
	private int sequence;
	private String number;
	private String name;
	private String remark;
	private int status;
	private List<Goods> goods;

	@OneToMany(cascade = { CascadeType.REFRESH }, mappedBy = "category")
	public List<Goods> getGoods() {
		return goods;
	}

	public void setGoods(List<Goods> goods) {
		this.goods = goods;
	}

	// JPA 基于profile_id列的多对一关系定义
	@ManyToOne
	@JoinColumn(name = "profile_id")
	public Profile getProfile() {
		return profile;
	}

	public void setProfile(Profile profile) {
		this.profile = profile;
	}

	public int getSequence() {
		return sequence;
	}

	public void setSequence(int sequence) {
		this.sequence = sequence;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	// 不持久化到数据库
	@Transient
	public String getStatusName() {
		return Status.alias(this.status);
	}
}
